package Demo9;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        //所需分配空间的进程数len
        int len = s.nextInt();
        int[] list = new int[64];
        list[2] = list[7] = list[13] = list[23] = list[37] = list[47] = list[59] = list[61] = 1;
        //len个进程每个所占用的内存数
        int[] array = new int[len];
        for (int i = 0; i < len; i++) {
            array[i] = s.nextInt();
        }
        int count = 0;
        for (int i = 0; i < list.length; i++) {
            if (list[i] != 1) {
                list[i] = 0;
            }
        }
        int lenth = list.length - 8;//当前仅剩的空闲区数量
        int sum = 0;
        int j = 0;
        for (int i = 0; i < array.length; i++) {
            sum += array[i];
            if (lenth - sum > 0) {
                while (j < list.length) {
                    if (list[j] == 0) {
                        count++;
                        if (count == array[i]) {
                            System.out.print(j++ + " ");
                            count = 0;
                            break;
                        }
                    }
                    j++;
                }
            } else if (lenth - sum < 0 || array[i] >= 64) {
                System.out.print("false ");
                sum -= array[i];
            }
        }


    }
}
